/*    */ package system.staros.sblock1;
/*    */ 
/*    */ import java.io.BufferedReader;
/*    */ import java.io.IOException;
/*    */ import java.io.Reader;
/*    */ import java.nio.CharBuffer;
/*    */ 
/*    */ public class PeekReader
/*    */ {
/*    */   private Reader in;
/*    */   private CharBuffer peakBuffer;
/*    */ 
/*    */   public PeekReader(Reader paramReader, int paramInt)
/*    */     throws IOException
/*    */   {
/* 39 */     if (!paramReader.markSupported())
/*    */     {
/* 41 */       paramReader = new BufferedReader(paramReader);
/*    */     }
/* 43 */     this.in = paramReader;
/* 44 */     this.peakBuffer = CharBuffer.allocate(paramInt);
/* 45 */     fillPeekBuffer();
/*    */   }
/*    */ 
/*    */   public void close() throws IOException {
/* 49 */     this.in.close();
/*    */   }
/*    */ 
/*    */   private void fillPeekBuffer() throws IOException {
/* 53 */     this.peakBuffer.clear();
/* 54 */     this.in.mark(this.peakBuffer.capacity());
/* 55 */     this.in.read(this.peakBuffer);
/* 56 */     this.in.reset();
/* 57 */     this.peakBuffer.flip();
/*    */   }
/*    */ 
/*    */   public int read() throws IOException {
/* 61 */     int i = this.in.read();
/* 62 */     fillPeekBuffer();
/* 63 */     return i;
/*    */   }
/*    */ 
/*    */   public int peek(int paramInt)
/*    */   {
/* 73 */     if ((paramInt < 1) || (paramInt > this.peakBuffer.capacity())) {
/* 74 */       throw new IndexOutOfBoundsException("lookAhead must be between 1 and " + this.peakBuffer.capacity());
/*    */     }
/* 76 */     if (paramInt > this.peakBuffer.limit()) {
/* 77 */       return -1;
/*    */     }
/* 79 */     return this.peakBuffer.get(paramInt - 1);
/*    */   }
/*    */ }

/* Location:           D:\Марк\!IMPORTANT\staros\archive\version-2.260.zip
 * Qualified Name:     system.staros.sblock1.PeekReader
 * JD-Core Version:    0.6.1
 */